﻿@model InspectionPlanModel
@using Nop.Web.Framework.Localization

@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Id)

<div class="content">
    <div class="form-horizontal">
        <div id="category-edit" class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                @Html.RenderBootstrapTabHeader("tab-info", new LocalizedString("基本信息"), true)
            </ul>
            <div class="tab-content">
                @Html.RenderBootstrapTabContent("tab-info", @TabInfo(), true)
            </div>
        </div>
    </div>
</div>

@{
    //custom tabs
    var eventMessage = new AdminTabStripCreated(this.Html, "category-edit");
    EngineContext.Current.Resolve<IEventPublisher>().Publish(eventMessage);
    foreach (var eventBlock in eventMessage.BlocksToRender)
    {
        @eventBlock
    }
}

@*save selected tab name*@
<input type="hidden" id="selected-tab-name" name="selected-tab-name" value="@(Html.GetSelectedTabName())">

@helper TabInfo()
{
    <div class="content" style="padding-bottom:0;">
        <div class="form-horizontal">
            <div class="panel-group">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.TypeName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.TypeName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.PNo)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.PNo)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                <div class="label-wrapper"><label class="control-label" for="Name" title="">计划名称</label></div>
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.Name)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.AimName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.AimName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.Content)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.Content)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.TeamName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.TeamName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.PersonName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.PersonName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.MaintenanceTeamName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.MaintenanceTeamName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.MaintenancePersonName)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.MaintenancePersonName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.StartOn)
                            </div>
                            <div class="col-md-9">
                                <div class="form-text-row">@Model.StartOn.ToString("yyyy-MM-dd")</div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.EndOn)
                            </div>
                            <div class="col-md-9">
                                <div class="form-text-row">@Model.EndOn.ToString("yyyy-MM-dd")</div>
                            </div>
                        </div>   
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.LossTime)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.LossTime)
                            </div>
                        </div>
                        @*<div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.LastUpdateOn)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.LastUpdateOn)
                            </div>
                        </div>*@
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.NopLabelFor(model => model.Published)
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.Published)
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="content" style="padding-top:0;">
        <div class="form-horizontal">
            <div class="panel-group">
                @if (Model.Id > 0)
                {
                    <div class="content-header clearfix" style="padding-top:0;">
                        <h1 class="pull-left">
                            巡检记录
                        </h1>
                        <div class="pull-right">
                        </div>
                    </div>
                    <div class="panel panel-default">
                        <div class="panel-body">
                            @{
                                var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
                                var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
                            }

                            <div id="inspections-grid"></div>

                            <script>
                            $(document).ready(function() {
                                $("#inspections-grid").kendoGrid({
                                    dataSource: {
                                        type: "json",
                                        transport: {
                                            read: {
                                                url: "@Html.Raw(Url.Action("Inspections", "InspectionPlan", new { planId = Model.Id}))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                        },
                                        schema: {
                                            data: "Data",
                                            total: "Total",
                                            errors: "Errors",
                                        },
                                        requestEnd: function(e) {
                                            if (e.type == "update") {
                                                this.read();
                                            }
                                        },
                                        error: function(e) {
                                            display_kendoui_grid_error(e);
                                            // Cancel the changes
                                            this.cancelChanges();
                                        },
                                        pageSize: @(defaultGridPageSize),
                                        serverPaging: true,
                                        serverFiltering: true,
                                        serverSorting: true
                                    },
                                    pageable: {
                                        refresh: true,
                                        pageSizes: [@(gridPageSizes)],
                                        @Html.Partial("_GridPagerMessages")
                                    },
                                    editable: {
                                        confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                        mode: "inline"
                                    },
                                    scrollable: false,
                                    columns: [{
                                            field: "Comment",
                                            title: "巡检说明",
                                            headerAttributes: { style: "text-align:center" },
                                        }, {
                                            field: "MaintenanceId",
                                            title: "报修编号",
                                            width: 150,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        template: '#if(MaintenanceId>0){# <a target="_blank" href="@Url.Content("~/Admin/Maintenance/View/")#=MaintenanceId#">#=XNo#</a> #}#'
                                        }, {
                                            field: "TeamName",
                                            title: "巡检班组",
                                            width: 120,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "CustomerName",
                                            title: "巡检人员",
                                            width: 100,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "CreatedOn",
                                            title: "巡检时间",
                                            width: 120,
                                            type: "date",
                                            format: "{0:yyyy/MM/dd}",
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        },]
                                });
                            });
                            </script>
                        </div>
                    </div>
                }
                else
                {
                    <div class="panel panel-default">
                        <div class="panel-body">
                            @T("Admin.Catalog.Categories.Products.SaveBeforeEdit")
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
    <div class="content" style="padding-top:0;">
        <div class="form-horizontal">
            <div class="panel-group">
                @if (Model.Id > 0)
                {
                    <div class="content-header clearfix" style="padding-top:0;">
                        <h1 class="pull-left">
                            漏检记录
                        </h1>
                        <div class="pull-right">

                        </div>
                    </div>
                    <div class="panel panel-default">
                        <div class="panel-body">
                            @{
                                var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
                                var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
                            }


                            <div id="loss-grid"></div>

                            <script>
                                $(document).ready(function() {
                                    $("#loss-grid").kendoGrid({
                                        dataSource: {
                                            type: "json",
                                            transport: {
                                                read: {
                                                    url: "@Html.Raw(Url.Action("Losss", "InspectionPlan", new { planId = Model.Id}))",
                                                    type: "POST",
                                                    dataType: "json",
                                                    data: addAntiForgeryToken
                                                },
                                            },
                                            schema: {
                                                data: "Data",
                                                total: "Total",
                                                errors: "Errors",
                                            },
                                            requestEnd: function(e) {
                                                if (e.type == "update") {
                                                    this.read();
                                                }
                                            },
                                            error: function(e) {
                                                display_kendoui_grid_error(e);
                                                // Cancel the changes
                                                this.cancelChanges();
                                            },
                                            pageSize: @(defaultGridPageSize),
                                            serverPaging: true,
                                            serverFiltering: true,
                                            serverSorting: true
                                        },
                                        pageable: {
                                            refresh: true,
                                            pageSizes: [@(gridPageSizes)],
                                            @Html.Partial("_GridPagerMessages")
                                        },
                                        editable: {
                                            confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                            mode: "inline"
                                        },
                                        scrollable: false,
                                        columns: [{
                                                field: "Comment",
                                                title: "未巡检说明",
                                                headerAttributes: { style: "text-align:center" },
                                            }, {
                                                field: "DayOn",
                                                title: "未巡检时间",
                                                width: 120,
                                                type: "date",
                                                format: "{0:yyyy/MM/dd}",
                                                headerAttributes: { style: "text-align:center" },
                                                attributes: { style: "text-align:center" },
                                            },
                                        ]
                                    });
                                });
                            </script>
                        </div>
                    </div>
                }
                else
                {
                    <div class="panel panel-default">
                        <div class="panel-body">
                            @T("Admin.Catalog.Categories.Products.SaveBeforeEdit")
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
    @*<div class="content" style="padding-top:0;">
            <div class="form-horizontal">
                <div class="panel-group">
                    @if (Model.Id > 0)
                    {
                        <div class="content-header clearfix" style="padding-top:0;">
                            <h1 class="pull-left">
                                报修记录
                            </h1>
                            <div class="pull-right">

                            </div>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-body">
                                @{
                                    var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
                                    var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
                                }


                                <div id="maintenances-grid"></div>

                                <script>
                            $(document).ready(function() {
                                $("#maintenances-grid").kendoGrid({
                                    dataSource: {
                                        type: "json",
                                        transport: {
                                            read: {
                                                url: "@Html.Raw(Url.Action("Maintenances", "InspectionPlan", new { planId = Model.Id}))",
                                                type: "POST",
                                                dataType: "json",
                                                data: addAntiForgeryToken
                                            },
                                        },
                                        schema: {
                                            data: "Data",
                                            total: "Total",
                                            errors: "Errors",
                                        },
                                        requestEnd: function(e) {
                                            if (e.type == "update") {
                                                this.read();
                                            }
                                        },
                                        error: function(e) {
                                            display_kendoui_grid_error(e);
                                            // Cancel the changes
                                            this.cancelChanges();
                                        },
                                        pageSize: @(defaultGridPageSize),
                                        serverPaging: true,
                                        serverFiltering: true,
                                        serverSorting: true
                                    },
                                    pageable: {
                                        refresh: true,
                                        pageSizes: [@(gridPageSizes)],
                                        @Html.Partial("_GridPagerMessages")
                                    },
                                    editable: {
                                        confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                        mode: "inline"
                                    },
                                    scrollable: false,
                                    columns: [{
                                            field: "SNo",
                                            title: "报修单号",
                                            width: 80,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "Name",
                                            title: "设施设备",
                                            width: 150,
                                            headerAttributes: { style: "text-align:center" },
                                        }, {
                                            field: "DepartmentName",
                                            title: "发起部门",
                                            width: 100,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "CustomerName",
                                            title: "发起人",
                                            width: 80,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "TeamName",
                                            title: "维修班组",
                                            width: 100,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "MaintenancePersonName",
                                            title: "维修人",
                                            width: 80,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                            template: '# if(MaintenancePersonName) {#<span>#=MaintenancePersonName#</span>#} else {#<span>#=PersonName??""#</span>#} #',
                                        }, {
                                            field: "CreatedOn",
                                            title: "开始时间",
                                            width: 100,
                                            type: "date",
                                            format: "{0:yyyy/MM/dd}",
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "MaintenanceOn",
                                            title: "完工时间",
                                            width: 100,
                                            type: "date",
                                            format: "{0:yyyy/MM/dd}",
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "Hours",
                                            title: "工时(时)",
                                            width: 80,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "Star",
                                            title: "评分",
                                            width: 80,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "Comment",
                                            title: "评价内容",
                                            width: 100,
                                            headerAttributes: { style: "text-align:center" },
                                        }, {
                                            field: "StateName",
                                            title: "状态",
                                            width: 80,
                                            headerAttributes: { style: "text-align:center" },
                                            attributes: { style: "text-align:center" },
                                        },
                                    ]
                                });
                            });
                                </script>
                            </div>
                        </div>
                    }
                    else
                    {
                        <div class="panel panel-default">
                            <div class="panel-body">
                                @T("Admin.Catalog.Categories.Products.SaveBeforeEdit")
                            </div>
                        </div>
                    }
                </div>
            </div>
        </div>*@
}
